* Asia sample
** This do-file replicates table 5 in 
** Pl�mper, Thomas and Eric Neumayer. 2010. The Level of Democracy during Interregnum Periods: Recoding the polity2 Score, Political Analysis, 18 (2)
** To replicate the results, save the data-file of the same name into your working directory and run this do-file

use "PA replication_K&S (Asia).dta", replace
capture mi extract 0, clear

* model 5.1 K&S original result
xtgee cow2cwo lngdppc lntpop lmtnest ncontig  oil  nwstate instab ethfrac relfrac lnmxtp lntgdp reg regsq , fam(bin) link(logit) corr(ar1) i(ccode) t(year) force robust
test reg regsq

* model 5.2 
xtgee cow2cwo lngdppc lntpop lmtnest ncontig  oil  nwstate instab ethfrac relfrac lnmxtp lntgdp polity2min polity2minsq , fam(bin) link(logit) corr(ar1) i(ccode) t(year) force robust
test polity2min polity2minsq

* model 5.3
** polity2pred does not achieve convergence; use instead polity2rev based on theoretical determinants of democracy only
xtgee cow2cwo lngdppc lntpop lmtnest ncontig  oil  nwstate instab ethfrac relfrac lnmxtp lntgdp polity2rev polity2revsq , fam(bin) link(logit) corr(ar1) i(ccode) t(year) force robust
test polity2rev polity2revsq

* model 5.4
capture drop *reg_imp*
ge reg_imp=reg
replace reg_imp=. if interplusafftrans==1

capture mi extract 0, clear
mi set wide
mi register imputed reg_imp 
mi impute mvn   reg_imp = cow2cwo lngdppc lntpop lmtnest ncontig  oil  nwstate instab ethfrac relfrac lnmxtp lntgdp , add(100) replace force rseed(2349)
capture drop regsq_imp
mi passive: ge regsq_imp = reg_imp*reg_imp
mi estimate, dots cmdok: xtgee cow2cwo lngdppc lntpop lmtnest ncontig  oil  nwstate instab ethfrac relfrac lnmxtp lntgdp reg_imp regsq_imp , fam(bin) link(logit) corr(ar1) i(ccode) t(year) force robust
mi test reg_imp regsq_imp

* model 5.5
capture drop *reg_imp*
ge reg_imp=reg
replace reg_imp=. if interplusafftrans==1

capture mi extract 0, clear
mi set wide
mi register imputed reg_imp 
mi impute mvn   reg_imp = polity2min  polity2max, add(100) replace force rseed(2349)
mi impute mvn   reg_imp = polity2min  polity2max fhpr fhcl if year>1972, replace force rseed(2349)
capture drop regsq_imp
mi passive: ge regsq_imp = reg_imp*reg_imp
mi estimate, dots cmdok: xtgee cow2cwo lngdppc lntpop lmtnest ncontig  oil  nwstate instab ethfrac relfrac lnmxtp lntgdp reg_imp regsq_imp , fam(bin) link(logit) corr(ar1) i(ccode) t(year) force robust
mi test reg_imp regsq_imp

* model 5.6
capture drop *reg_imp*
ge reg_imp=reg
replace reg_imp=. if interplusafftrans==1

capture mi extract 0, clear
mi set wide
mi register imputed reg_imp 
mi impute mvn   reg_imp = cow2cwo lngdppc lntpop lmtnest ncontig  oil  nwstate instab ethfrac relfrac lnmxtp lntgdp polity2min polity2max , add(100) replace force rseed(2349)
mi impute mvn   reg_imp = cow2cwo lngdppc lntpop lmtnest ncontig  oil  nwstate instab ethfrac relfrac lnmxtp lntgdp polity2min polity2max  fhpr fhcl if year>1972, replace force rseed(2349)
capture drop regsq_imp
mi passive: ge regsq_imp = reg_imp*reg_imp
mi estimate, dots cmdok: xtgee cow2cwo lngdppc lntpop lmtnest ncontig  oil  nwstate instab ethfrac relfrac lnmxtp lntgdp reg_imp regsq_imp , fam(bin) link(logit) corr(ar1) i(ccode) t(year) force robust
mi test reg_imp regsq_imp

